<!--
 * @Author: gyc
 * @Date: 2020-06-05 11:14:53
 * @LastEditTime: 2020-06-12 08:38:15
 * @Description: Nuxt测试版
--> 
<template>
  <div class="index-search">
    <input type="text" placeholder="请输入相关信息" @focus="ifocus" @blur="nfocus" aria-placeholder />
    <Icon type="md-search" class="index-search-btn" size="24" color="white" />
    <div class="auto-search" v-if="isShow">
      <p>1</p>
      <p>2</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "indexSearch",
  data() {
    return {
      isShow: false
    };
  },
  methods: {
    ifocus() {
      this.isShow = true;
    },
    nfocus() {
      this.isShow = false;
    }
  }
};
</script>

<style lang="scss" scoped>
.index-search {
  position: relative;
  input {
    width: 300px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    outline: none;
    border: 0;
    text-indent: 20px;
    color: white;
    &:focus {
      box-shadow: 0px 0px 4px #ff5773;
      border: 1px solid #ff5773;
    }
  }
  input::-webkit-input-placeholder {
    /* WebKit browsers 适配谷歌 */
    color: white;
  }
  .index-search-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: pointer;
  }
  .auto-search {
    position: absolute;
    top: 45px;
    left: 0;
    width: 300px;
    z-index: 100;
    background-color: white;
    border-radius: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
    p {
      display: flex;
      align-items: center;
      width: 100%;
      padding-left: 10px;
      height: 24px;
      cursor: pointer;
      &:hover {
        background-color: rgba(255, 87, 115, 0.2);
      }
    }
  }
}
</style>
